/**
 * @Title: Convert.java
 * @Copyright (C) 2017 龙图软件
 * @Description:
 * @Revision History:
 * @Revision 1.0 2017-12-6  yuanchunci
 */
 

package com.ycc.uitl;

import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;

/**
 * @ClassName: Convert
 * @Description: Description of this class
 * @author <a href="mailto:XXX@qq.com">yuanchunci</a>于 2017-12-6 下午4:28:01
 */

public class Convert{
	 /**
	  * 将文件转换成流
	  * @param url
	  * @return
	  * @throws IOException
	  * @throws
	  */
	 public static byte[] convertTostream(String url) throws IOException{
		  File thumbnailFile=new File(url);
         FileInputStream fis = new FileInputStream(thumbnailFile);  
	      System.out.println(fis);
	      byte[] b = new byte[fis.available()];
	      ByteArrayOutputStream bos = new ByteArrayOutputStream(fis.available()); 
         int n;  
         while ((n = fis.read(b)) != -1) {  
             bos.write(b, 0, n);  
         }  
         fis.close();  
         bos.close();  
		return bos.toByteArray();
	 }
}
